package com.abel.servicegateway.config;

import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;
import springfox.documentation.swagger.web.SwaggerResource;
import springfox.documentation.swagger.web.SwaggerResourcesProvider;

import java.util.ArrayList;
import java.util.List;
@Primary
@Component
public class MySwaggerResourceProvider implements SwaggerResourcesProvider {
    @Override
    public List<SwaggerResource> get() {
        List<SwaggerResource> resources=new ArrayList<>();
        resources.add(swaggerResource("service-user","/user/v2/api-docs"));
        resources.add(swaggerResource("service-goods","/goods/v2/api-docs"));
        return resources;
    }
    private SwaggerResource swaggerResource(String name,String location){
        SwaggerResource swaggerResource=new SwaggerResource();
        swaggerResource.setName(name);
        swaggerResource.setLocation(location);
        swaggerResource.setSwaggerVersion("2.0");
        return  swaggerResource;
    }
}
